package com.bjsxt.controller;

import com.bjsxt.pojo.PageA;
import com.bjsxt.pojo.Role;
import com.bjsxt.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    /*查询所有角色信息*/
    @RequestMapping("/fingMoreRole")
    public PageA<Role> fingMoreRole(Integer page,Integer rows){
      return   roleService.findMoreRole(page, rows);
    }

    /*添加角色信息*/
    @RequestMapping("/saveRole")
    public Integer saveRole(Integer[] mids,Role role){

        return roleService.savaRole(mids,role);
    }

    //查询指定角色下的编号的信息
    @RequestMapping("/findMenuMid")
    public List<Integer> findMenuMid(Integer rid){
       return roleService.findMoreMID(rid);
    }


    //修改角色的信息
    @RequestMapping("/updateRole")
    public Integer updateRole(Role role,Integer [] mids){
        return roleService.updateRole(role,mids);
    }
    //删除角色的信息
    @RequestMapping("/deleteRole")
    public Integer deleteRole(Integer rid){
       return roleService.deleteRole(rid);
    }

    //查询所有的角色信息
    @RequestMapping("/findAllRole")
    public List<Role> findAllRole(){
       return roleService.findAllRole();
    }

}
